TreeViewCustomNode is a class to make custom rendered TreeView nodes and possibly with custom functionality.
Note:You can inherit from the TreeViewCustomNode and add your own data properties to it. In fact the way to make your custom rendered node is to inherit from the TreeViewCustomNode class and hook your custom code into its events.
Warning:A TreeViewCustomNode can not be reused in any way. This means that a node may not be put in two different TreeView controls or twice in the same unless if the node has first been removed from the TreeView that it was in.
TreeViewNode
TreeViewCustomNode
class TreeViewCustomNode
Constructors
Properties
DarkModeImage (Inherited) | Image to be used when in dark mode. |
FontBold (Inherited) | Set this property to true to let the node text be drawn bold faced. |
FontItalic (Inherited) | Set this property to true to let the node text be drawn italic faced. |
FontUnderline (Inherited) | Set this property to true to let the node text be drawn with text underline style. |
HasExpander (Inherited) | Use this property to force a node to have a expander even if it has no child nodes. |
HasTextColor (Inherited) | If set to true then TextColor property is active and will override Text color setting coming from the TreeView Control. |
Image (Inherited) | Sets or gets the node image. |
ItemData (Inherited) | A property to store custom data on the node. |
Text (Inherited) | Sets or gets the text of a node. |
TextColor (Inherited) | Sets the text color of a node. |
Methods
AddSubItem (Inherited) | Adds text to additional columns of the node. |
AddSubItem (Inherited) | Adds text and alignment to additional columns of the node. |
AppendNode (Inherited) | Appends a child node to the current node. |
Depth (Inherited) | Returns the depth of the node in the tree. |
Expanded (Inherited) | Returns true if the node is expanded. |
GetTextOffset (Inherited) | Returns x location where text starts to draw on a node, taking into account indents, expanders and icons. |
Index (Inherited) | Returns the Screen Index of the node. |
IndexOf (Inherited) | Finds a index of a child node relative to the parent. |
InsertNode (Inherited) | Inserts a child node at a given index to the current node. |
ItemAlignment (Inherited) | Sets or gets the alignment for a specific column. |
ItemText (Inherited) | Sets or gets the text for a specific column. |
Node (Inherited) | Returns a child node at a given index. |
NodeCount (Inherited) | Returns the count of child nodes. |
RemoveChild (Inherited) | Removes a child node. |
RemoveChildAt (Inherited) | Removes a child node at a index that is relative to the parent node. |
Selected (Inherited) | Returns true if the node is currently selected. |
SetExpanded (Inherited) | Expands or collapses the node. |
SetItemIndent (Inherited) | Sets Left or Right indent for the sub item |
SortNodes (Inherited) | Sorts children of the node, using compare delegate to compare the nodes. |
Swap (Inherited) | Swaps child nodes of the given node instance. |
Events
DrawBackground | Draws the background of a node. |
DrawForeground | Draws the foreground of a node. |
MouseDown | This Event is fired when mouse goes down in the custom node. |
MouseDrag | This Event is fired when mouse is dragged over the custom node after mouse has gone down there and true was returned from the mouse down event. |
MouseUp | This Event is fired when mouse buttons goes up in the custom node after mouse has gone down there and true was returned from the mouse down event. |
Example
Sub DrawForeground(g as Graphics,ByRef textYOffset as Integer, offset as Integer,owner as TreeView, isDarkMode as Boolean)
Dim img as Picture
Dim img2 as Picture
if State = 0 then
img = SuccessImage
else
img = FailImage
end if
if IsDown then
img2 = NewPicture(img.Width,img.Height,32)
img2.Graphics.DrawPicture(img,0,0)
img2.Mask.Graphics.DrawPicture(SuccessMaskImageFaded,0,0)
g.DrawPicture img2,g.Width - 18,1
else
g.DrawPicture img,g.Width - 18,1
end if
ButtonStart = g.Width - 18
End Sub
Function MouseDown(x as Integer,y as Integer,owner as TreeView) As Boolean
if x > ButtonStart and x < ButtonStart + 15 and y > 2 and y < 18 then
IsDown = true
return true
end if
return false
End Function
Function MouseDrag(x as Integer,y as Integer,owner as TreeView) As Boolean
if x > ButtonStart and x < ButtonStart + 15 and y > 2 and y < 18 and IsDown = false then
IsDown = true
return true
elseif not (x > ButtonStart and x < ButtonStart + 15 and y > 2 and y < 18) and IsDown = true then
IsDown = false
return true
end if
return false
End Function
Function MouseUp(x as Integer,y as Integer,ByRef triggerAction as Boolean,owner as TreeView) As Boolean
IsDown = false
if x > ButtonStart and x < ButtonStart + 15 and y > 2 and y < 18 then
triggerAction = true
if State = 0 then
State = 1
else
State = 0
end if
end if
return true
End Function
Supported Platforms:
macOS Intel 32 bitmacOS Intel 64 bitmacOS Apple SiliconWindows 32 bitWindows 64 bitWindows ARM 64 bitLinux 32 bitLinux 64 bitLinux ARM 32 bitLinux ARM 64 bit